//
//  SamplePhotoCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/3.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "SamplePhotoCell.h"

@interface SamplePhotoCell ()
@property(nonatomic, strong) UIView *bottomView;
@property(nonatomic, strong) UILabel *titleLabel;
@end

@implementation SamplePhotoCell

- (void)awakeFromNib {
    [super awakeFromNib];

}

- (void)fillCellWithModel:(CommonOpusModel *)model {
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.transverseImg] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    self.titleLabel.text = model.opusName;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.mainImageView.frame = CGRectMake(12, 5, self.width - 24, self.height - 10);
    [self.mainImageView pp_clipCorners:UIRectCornerAllCorners radius:6 border:0.5 color:UIColorHex(0xf1f1f1)];
    [self.mainImageView addSubview:self.bottomView];
    self.bottomView.frame = CGRectMake(0, self.mainImageView.height - 30, self.mainImageView.width, 30);
    self.bottomView.backgroundColor = [UIColor colorWithGradientStyle:UIGradientStyleTopToBottom withFrame:self.bottomView.bounds andColors:@[rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8)]];
    [self.bottomView addSubview:self.titleLabel];
    self.titleLabel.frame = CGRectMake(12, 0, self.bottomView.width - 24, self.bottomView.height);
}
#pragma mark - lazy
- (UIView *)bottomView {
    if (!_bottomView) {
        _bottomView = [[UIView alloc]init];
    }
    return _bottomView;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        UILabel *lab = [[UILabel alloc]init];
        lab.font = kFontRegular(12);
        lab.textColor = UIColor.whiteColor;
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 1;
        _titleLabel = lab;
    }
    return _titleLabel;
}
@end
